import plugins.GetPImageIF;
import plugins.InnerIF;
import processing.core.PApplet;
import processing.core.PImage;

public class RollPreview extends PApplet implements GetPImageIF {
	// HashMap<String, InnerIF> sketchToPreview;
	InnerIF[]	sketchToPreview;
	// String myRollName;
	int			myRollName;
	private int	width			= 320;
	private int	height			= 240;
	PImage		previewImage	= new PImage(width * 2, height * 2);	// wada

	// public void init(HashMap<String, InnerIF> activeSketchOfRoll, String
	// rollName) {
	public void init(InnerIF[] activeSketchOfRoll2, int rollName) {
		super.init();
		// sketchToPreview = activeSketchOfRoll;
		sketchToPreview = activeSketchOfRoll2;
		myRollName = rollName;
	}

	@Override
	public void setup() {
		System.out.println("RollPreview started.");
		size(width, height, P2D);
		frameRate(3);
	}

	//
	@Override
	public void draw() {
		// if (sketchToPreview.get(myRollName) != null)
		// (sketchToPreview.get(myRollName)).getPImage(previewImage);
		// if (sketchToPreview[myRollName] != null)
		// (sketchToPreview[myRollName]).getPImage(previewImage);
		if (sketchToPreview[myRollName] != null) image(sketchToPreview[myRollName].getPImage(), 0, 0, width, height);

	}

	@Override
	public void mousePressed() {
		System.out.println("mouse pressed.");
	}

	@Override
	public void mouseDragged() {
	}

	@Override
	public void mouseReleased() {
	}

	@Override
	public PImage getPImage() {
		loadPixels();
		return get();
	}

}
